<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<div id="loginFormContainer">
	<form action="/etown/login.action" method="post" id="loginForm">
		<table width="100%">
			<tr>
				<td width="45%" align="right">
					<label for="userName">
						<span class="required">用户名：</span>
					</label>
				</td>
				<td>
					<input id="userName" name="userName" type="text"/>
				</td>
			</tr>
			<tr>
				<td width="45%" align="right">
					<label for="password">
						<span class="required">密码：</span>
					</label>
				</td>
				<td>
					<input id="password" name="password" type="password"/>
				</td>
			</tr>
			<tr>
				<td align="center" colspan="2">
					<input type="checkbox" checked="checked">自动登录
				</td>
			</tr>
			<tr>
				<td align="center" colspan="2">
					<button type="submit">
						登录
					</button>
					<button id="toRegistBtn" type="button">
						注册
					</button>
					<button id="toForgotPwd" type="button">
						忘记密码
					</button>
				</td>
			</tr>
		</table>
	</form>
</div>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/loginModule.css" />
<script src="${pageContext.request.contextPath}/common/jquery-validate/jquery.validate.js"	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/common/jquery-validate/localization/messages_cn.js"	type="text/javascript"></script>

<script type="text/javascript">
	$(document).ready(function(){
		//userName只能是字母、数字、下划线
		$.validator.addMethod("userName", function(value, element) {   
		  	return this.optional(element) || /^\w+$/.test(value);   
		});
		$("#loginForm").validate({
			rules:{
				userName:{
					required:true,
					userName:true,
					minlength:4,
					maxlength:12
				},
				password:{
					required:true,
					minlength:6,
					maxlength:16
				}
			},
			messages: {
				userName:{
					userName:"只能是字母、数字、下划线"
				}
			},
			focusInvalid:false,
 			onkeyup:false
		});
		
		$("#toRegistBtn").click(function(){
			window.location.href="${pageContext.request.contextPath}/usermng/regist.jsp";
		});
		$("#toForgotPwd").click(function(){
			window.location.href="${pageContext.request.contextPath}/usermng/forgotPwd.jsp";
		});
		$("#userName").focus();
	})
</script>

<c:if test="${errorMsg!=null}">
	<script type="text/javascript">
		showSysMsg("${errorMsg}");
	</script>
</c:if>